package com.ny.zmb.openapi.jh;

import com.alibaba.fastjson.JSONObject;

public enum  JhEnum {

    success(0,"操作成功"),
    param_is_notnull(1001,"参数为空"),
    param_gs(1002,"参数格式不正确"),
    param_value(1003,"参数值不正确"),
    param_cf(1004,"参数重复"),
    param_rc(1004,"入参转化错误"),

    permission_apply_create_sh(2000,"申请售后创建创建失败"),
    permission_user(2001,"用户权限不足"),
    permission_ht(2002,"合同权限不足"),
    permission_qy(2003,"企业权限不足"),
    permission_goods(2004,"商品池权限不足"),
    permission_jc(2005,"商品池权限不足"),
    permission_zp(2006,"无有效专票资质"),
    permission_token(2007,"token 已过期"),

    orders_token(3001,"价格不存在"),
    orders_apply(3002,"提交订单过快"),
    orders_lx_no_supput(3003,"提交订单过快 订单类型只支持普通自营、厂家直送、实物礼品卡、延保商品"),
    orders_lx_no(3004,"商品类型受限制"),
    orders_goods_auth(3005,"商品没查询到"),
    orders_goods_pay(3006,"商品不能进行货到付款下单"),
    orders_goods_address(3007,"地址不能进行货到付款下单"),
    orders_goods_kc(3008,"库存不足"),
    orders_goods_area(3009,"该区域不支持配送"),
    orders_goods_hh(3010,"实体礼品卡和其他实物不能混合下单"),
    orders_goods_tq(3011,"大家电暂不支持公司转账预占下单"),
    orders_goods_he(3012,"海尔仓大家电，不支持后款预占下单"),
    orders_goods_zs(3013,"厂家直送商品只能下先款订单"),
    orders_goods_zs_(3014,"厂家直送商品不能使用普票随货下单"),
    orders_goods_card(3015,"实物礼品卡订单只能下普票订单"),
    orders_goods_card_bz(3016,"配额不足或者已被锁定"),
    orders_goods_balance(3017,"余额不足"),
    orders_goods_sku(3018,"客户端价格快照中 sku 价格不存在"),
    orders_goods_price(3019,"客户端价格快照中 sku 价格与价格不一致"),
    orders_goods_skuinfo(3028,"不支持货到付款，并有 skuIds 明细返回"),
    orders_goods_get_price(3051,"价格获取失败"),
    orders_goods_get_data(3052,"主数据接口业务异常"),
    orders_goods_get_detail(3053,"商品基本信息接口调用失败"),
    orders_goods_get_detail_kz(3054,"商品扩展接口调用失败"),
    orders_goods_jd(3055,"大家电接口调用失败"),
    orders_goods_zp(3056,"赠品附件接口调用失败"),
    orders_goods_qf(3057,"区分大家电和中小件商品失败"),
    orders_goods_zf(3058,"下单失败，请重新提交订单"),
    orders_goods_qr(3101,"确认下单最终失败，请重新确认订单"),
    orders_goods_orders_no(3102,"orderNo 不存在"),
    orders_goods_orders_yzf(3103,"该订单已确认下单"),
    orders_goods_orders_dxd(3104,"不能单独确认子订单"),
    orders_goods_orders_cannel(3105,"订单对应子单已取消，不能确认！"),
    orders_goods_orders_yc(3106,"查询子单异常"),
    orders_goods_orders_erp(3107,"本地子单与 ERP 子单不一致"),
    orders_goods_orders_qr(3108,"确认订单操作失败"),
    orders_goods_cannel_order(3201,"取消订单失败，请重新取消订单"),
    orders_goods_cannel_order_no(3202,"orderNo 不存在"),
    orders_goods_order_no(3203,"该订单已经被取消"),
    orders_goods_cannel_create_orders(3204,"不能取消已经生产订单"),
    orders_goods_cannel_orders(3205,"不能取消未确认订单"),
    orders_goods_cannel_qr_orders(3206,"不能取消预占并且已确认订单"),
    orders_goods_cannel_fz_orders(3207,"不能取消父订单"),
    orders_goods_cannel_yqr_orders(3208,"不能取消已确认订单"),
    orders_cannel_orders(3209,"不能取消子订单"),
    orders_look_son_orders(3210,"查询子单异常"),
    orders_cannel_son_orders(3210,"取消订单失败，存在已确认的子单"),
    orders_cannel_orders_fail(3212,"取消订单操作失败"),
    orders_fp_dsh(3301,"待审核"),
    orders_fp_bh(3302,"驳回"),
    orders_fp_tgdkp(3303,"通过待开票"),
    orders_fp_qdbcz(3304,"申请单不存在"),
    orders_other_bcz(3401,"订单不存在"),
    orders_other_psbcz(3402,"订单配送信息不存在"),
    orders_other_zfye(3403,"支付时余额不足"),
    orders_other_bnfqzf(3404,"订单不能发起支付"),
    orders_other_address(3405,"没查询到对应地址"),
    orders_other_jgbcz(3406,"价格不存在"),
    orders_other_yeyc(3407,"获取余额业务异常"),
    orders_other_zflx(3408,"该支付类型不支持余额查询"),
    orders_other_qf(3409,"区分大家电和中小件商品失败"),
    orders_other_wgq(3410,"订单未被挂起"),
    orders_other_gfl(3422,"获取分类列表信息失败"),
    orders_other_flbcz(3423,"分类列表不存在"),
    getOrders_other_address(3554,"地址非法-非地址"),


    sys_yc(5001,"服务异常，请稍后重试"),
    sys_wz(5002,"未知错误"),

    after(6000,"未知错误"),
    after_param(6001,"参数不正确"),
    after_order(6002,"该订单不存在"),
    after_order_tj(6003,"该订单未确认提交"),
    after_order_noson(6004,"该订单不是子订单"),
    after_order_nwtt(6005,"该订单未妥投"),
    after_order_fail(6006,"该订单不是正常订单"),
    after_goods_nobh(6007,"订单没有该商品编号"),
    after_goods_wwc(6008,"该订单是未完成订单"),
    after_no_sh(6009,"订单中某商品不可以提交售后服务"),
    after_no_order(6010,"订单中某商品不可以提交售后服务"),
    after_no_order_re(6011,"不属于商品返回方式"),
    after_order_fw(6012,"不属于支持的服务类型"),
    after_order_sh(6013,"服务单未通过审核"),



    other_ff(9001,"不存在方法"),
    other_ff_clientid(9101,"不存在 clientid 请联系供应商"),
    other_ff_ip(9102,"访问的 ip 地址错误请联系供应商"),
    other_ff_user(9103,"用户名密码错误请联系供应商"),
    other_re_token(9104,"刷新令牌错误请重新获取新的刷新令牌"),
    other_token(9121,"令牌错误"),
    other_order_yf(9151,"订单中获取运费失败"),
    other_son(9152,"部分子订单失败"),
    other_address(9153,"确认收货失败，该订单无法确认收货"),
    other_cannel(9154,"取消确认失败，该订单不是预占库存成功状态"),
    other_fy(9155,"填写发运信息失败，该订单不是可以填写发运信息的状态"),
    other_qr_orders(9156,"确认订单失败，该订单状态不是可以确认的订单状态"),
    other_sy(9157,"上游返回订单号不存在"),
    other_sq_after(9180,"该订单已经申请过售后"),
    other_cannel_order(9190,"取消售后订单失败"),
    other_bd(9800,"本地添加订单异常"),
    other_yb(9801,"获取延保商品异常"),
    other_no_yb(9802,"商品没有延保信息"),
    other_kk(9900,"本地扣款调用异常"),
    other_sy_fail(9902,"上游接口调用异常"),
    other_sy_goods(9903,"上游接口分发调用异常"),
    other_sy_data(9903,"上游接口返回数据格式化异常"),
    other_sy_wz(9910,"上游接口未知错误"),
    other_session(9999,"会接口未知错误"),
    ;

    JhEnum(Integer code,String msg){
        this.code = code;
        this.msg = msg;
    }

    private Integer code;

    private String msg;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static JSONObject get(JSONObject json){
        JhEnum[] values = JhEnum.values();
        for (JhEnum value : values) {
            if (value.getCode().equals(json.getInteger("code"))){
                json.put("msg",value.msg);
                return json;
            }
        }
        return json;
    }

    public static void main(String[] args) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code",0);
        JSONObject jsonObject1 = get(jsonObject);
        System.out.println(jsonObject1);
    }
}
